package br.com.robot;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import br.com.robot.implement.Nuuvem;
import br.com.robot.implement.Steam;

public class RobotList 
{
	private        List<RobotBean>  lista     = new ArrayList<RobotBean>( );
	private static RobotList        container;

	public static final int ID_STEAM_ROBOT  = 1;
	public static final int ID_NUUVEM_ROBOT = 2;
	
	private RobotList( )
	{
		RobotBean[] array =
		{
			new RobotBean( ID_STEAM_ROBOT,  "Steam-robot",  Steam.class  ),
			new RobotBean( ID_NUUVEM_ROBOT, "Nuuvem-robot", Nuuvem.class ),
		};
		
		this.lista = Arrays.asList( array );
	}
	
	public static RobotList getContainer( )
	{
		if( container == null )
			container = new RobotList( );
		
		return container;
	}
	
	public List<RobotBean> getLista( ) 
	{
		return lista;
	}
	
	/**
	 * Use os Enumerados desta classe<br>
	 * @param id 
	 * @return
	 */
	public RobotBean getRobotBean( int id ) 
	{
		for( RobotBean robotBean : lista )
		{
			if( robotBean.getId( ) == id )
				return robotBean;
		}
		
		return null;
	}
	
	public List<RobotBean> getRobotBean( int... ids ) 
	{
		List<RobotBean> lst = new ArrayList<RobotBean>( );
		
		for( RobotBean robotBean : lista )
		{
			for( int id : ids )
			{
				if( robotBean.getId( ) == id )
					lst.add( robotBean );
			}
		}
		
		return lst;
	}
}